package com.bilgeadam.hibernate.program;

import java.util.List;

import com.bilgeadam.hibernate.model.DbUtil;
import com.bilgeadam.hibernate.model.entity.Employee;

/**
 * 
 * @author Bora SAYINER
 * @since Nov 21, 2014 3:51:26 PM
 * @version 1.0.0
 */
@SuppressWarnings("unused")
public class Driver {

	public static void main(String[] args) {
		// addEmployeeTest();
		// getAllEmployeeTest();
		// findEmployeeByIdTest();
		// updateEmployeeTest();
		// deleteEmployeeTest();
	}

	private static void deleteEmployeeTest() {
		Employee employee = DbUtil.getInstance().getEmployees().findById(1L);
		boolean result = DbUtil.getInstance().getEmployees().delete(employee);
		System.out.println(result);
	}

	private static void updateEmployeeTest() {
		Employee employee = DbUtil.getInstance().getEmployees().findById(1L);
		employee.setFirstName("Ahmet");
		DbUtil.getInstance().getEmployees().update(employee);
	}

	private static void findEmployeeByIdTest() {
		Employee employee = DbUtil.getInstance().getEmployees().findById(1L);
		System.out.println(employee);
	}

	private static void getAllEmployeeTest() {
		List<Employee> employees = DbUtil.getInstance().getEmployees().getAll();
		for (Employee employee : employees) {
			System.out.println(employee);
		}
	}

	private static void addEmployeeTest() {
		Employee employee = new Employee();
		employee.setFirstName("Ali");
		employee.setLastName("Veli");
		employee.setSalary(2200);
		DbUtil.getInstance().getEmployees().add(employee);
	}
}
